﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using SapB1WebPOS.DAL;
using SapB1WebPOS.Utils;

namespace SapB1WebPOS.BLL
{
    public class PermissionBLL
    {
        public string UpdateOnlineUserPermission(string companyDB, string userName, string purchaseOrder,
            string purchaseRequest, string salesQuotation, string salesOrder, string grpo, string pos)
        {
            try
            {
                DataSet ds = new DataSet("@USER");
                PermissionDAO connect = new PermissionDAO();
                return connect.UpdateOnlineUserPermission(companyDB, userName, purchaseOrder, purchaseRequest, salesQuotation, salesOrder, grpo, pos);
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return ex.Message;
            }
        }
        public string OnlineUserChangePassword(string companyDB, string userName, string newPassword)
        {
            try
            {
                DataSet ds = new DataSet("@USER");
                PermissionDAO connect = new PermissionDAO(); 
                return connect.OnlineUserChangePassword(companyDB, userName, newPassword);
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return ex.Message;
            }
        }
        public DataSet GetAllOnlineUser(string companyDB)
        {
            try
            {
                DataSet ds = new DataSet("@USER");
                PermissionDAO connect = new PermissionDAO();
                ds = connect.GetAllOnlineUser(companyDB);
                return ds;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
        public DataSet GetOnlineUserByUserName(string companyDB, string userName, string passWord)
        {
            try
            {
                DataSet ds = new DataSet("@USER");
                PermissionDAO connect = new PermissionDAO();
                ds = connect.GetOnlineUserByUserName(companyDB, userName, passWord);
                return ds;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
    }
}